#-*- coding: utf-8 -*-
from django.db import models

# Create your models here.
class Publisher(models.Model):
    name = models.CharField(max_length=30)
    address = models.CharField(max_length=50)
    city = models.CharField(max_length=60)
    state_province = models.CharField(max_length=30)
    country = models.CharField(max_length=50)
    website = models.URLField()

    def __unicode__(self):
        return self.name

    class Meta:
        ordering = ['name']

class Author(models.Model):
    salutation = models.CharField(max_length=10)
    first_name = models.CharField(u'имя', max_length=30)
    last_name = models.CharField(max_length=40, verbose_name=u"фамилия")
    email = models.EmailField(blank=True, verbose_name="e-mail")
    #headshot = models.ImageField(upload_to='/tmp')

    def __unicode__(self):
        return '%s %s' % (self.first_name, self.last_name)

class Book(models.Model):
    title = models.CharField('заголовок',max_length=100)
    authors = models.ManyToManyField(Author, verbose_name=u'авторы')
    publisher = models.ForeignKey(Publisher, verbose_name=u'издательство')
    publication_date = models.DateField(blank=True,null=True, verbose_name=u'дата пубилкации')

    def __unicode__(self):
        return self.title
